home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 422_04 / mc_vs_sc.doc < prev    next >
Text File  |  1994-03-20  |  22KB  |  504 lines

  1.     
  2.     
  3.     
  4.     
  5.     
  6.     
  7.     
  8.     
  9.     
  10.     
  11.     
  12.     
  13.                                        A
  14.                                    Comparison
  15.                                        of
  16.     
  17.     
  18.           ===========================================================
  19.           MM   MM  IIIIIII    CCCC   RRRRRR     OOO             CCCC
  20.           M M M M     I      C    C  R     R   O   O           C    C
  21.           M  M  M     I     C        R     R  O     O         C
  22.           M     M     I     C        RRRRRR   O     O  -----  C
  23.           M     M     I     C        R   R    O     O         C
  24.           M     M     I      C    C  R    R    O   O           C    C
  25.           M     M  IIIIIII    CCCC   R     R    OOO             CCCC
  26.           ===========================================================
  27.           
  28.                                      A N D
  29.           
  30.           ===========================================================
  31.            SSSSS   MM   MM     A     L        L                 CCCC
  32.           S     S  M M M M    A A    L        L                C    C
  33.           S        M  M  M   A   A   L        L               C
  34.            SSSSS   M     M  A     A  L        L        -----  C
  35.                 S  M     M  AAAAAAA  L        L               C
  36.           S     S  M     M  A     A  L        L                C    C
  37.            SSSSS   M     M  A     A  LLLLLLL  LLLLLLL           CCCC
  38.           ===========================================================
  39.     
  40.     
  41.     
  42.     
  43.     
  44.     
  45.     
  46.     
  47.     
  48.     
  49.     
  50.     
  51.     
  52.     
  53.     
  54.                        Copyright 1990-1994 Dave Dunfield
  55.                               All rights reserved
  56.     MICRO-C .vs. SMALL-C                                             Page: 1
  57.  
  58.  
  59.     1. INTRODUCTION
  60.     
  61.           The most common reaction of people hearing about DDS  MICRO-C  for
  62.        the first time is something like "Humph... Another version of the old
  63.        SMALL-C compiler". This couldn't be further from the truth.
  64.     
  65.                            MICRO-C IS NOT SMALL-C!!!
  66.     
  67.           MICRO-C is a completely  new  implementation  of  a  'C'  compiler
  68.        suitable for use on very small systems. It offers several  advantages
  69.        over SMALL-C:
  70.     
  71.         - It was designed from the  ground  up  to  be  easily  portable  to
  72.           different processors & computer  platforms.  Code  generators  are
  73.           available for 8080, 8051, 80x86, 8096,  6809,  68HC11  and  68HC16
  74.           cpu's, and an entire section of the manual is devoted  to  porting
  75.           the compiler.
  76.     
  77.           Although SMALL-C claims  to  be  easily  portable,  much  of  it's
  78.           arcitecture is oriented toward the original 8080 processor. For an
  79.           example of  how  this  affects  the  compiler,  compare  the  code
  80.           generated by the 8086 version of SMALL-C to reference stack (auto)
  81.           variables to that produced by MICRO-C.
  82.     
  83.         - It is a more complete implementation of the 'C' language, see  the
  84.           features comparison later in this document.
  85.     
  86.         - It produces faster, more compact code. See the  benchmark  results
  87.           later in this document.
  88.     
  89.         - MICRO-C employs  a  fully  tokenized  parser,  allowing  statement
  90.           analysis to be performed  on  16  bit  "tokens"  instead  of  text
  91.           strings as is  done  in  SMALL-C.  This  results  in  MUCH  faster
  92.           compilation.
  93.     
  94.         - Although it is higher in functionality than SMALL-C,  the  MICRO-C
  95.           compiler is much smaller than SMALL-C (Nearly half the size). This
  96.           allows it to run on very small computer systems.
  97.     
  98.     2. DETAILED COMPARISON OF COMPILERS
  99.     
  100.           The following pages contain a detailed comparison of  the  SMALL-C
  101.        version 2 compiler, and MICRO-C.
  102.     MICRO-C .vs. SMALL-C                                             Page: 2
  103.  
  104.  
  105.        2.1 'C' Implementation
  106.             = Data Types ===========+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
  107.             int                     |    Yes     |    Yes     |   Yes   |
  108.             char                    |    Yes     |    Yes     |   Yes   |
  109.             unsigned int            |     No     |     No     |   Yes   |
  110.             unsigned char           |     No     |     No     |   Yes   |
  111.             pointers                |    Yes     |    Yes     |   Yes   |
  112.             pointers to pointers    |     No     |     No     |   Yes   |
  113.             structs & unions        |     No     |     No     |   Yes   |
  114.             Single dimension arrays |    Yes     |    Yes     |   Yes   |
  115.             Multi dimension arrays  |     No     |     No     |   Yes   |
  116.             Arrays of pointers      |     No     |     No     |   Yes   |
  117.             Arrays of structs       |     No     |     No     |   Yes   |
  118.             Typecast                |     No     |     No     |   Yes   |
  119.             sizeof                  |     No     |     No     |   Yes   |
  120.             Static globals & locals |     No     |     No     |   Yes   |
  121.             = Control Structures ===+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
  122.             if/else                 |    Yes     |    Yes     |   Yes   |
  123.             while                   |    Yes     |    Yes     |   Yes   |
  124.             do/while                |     No     |    Yes     |   Yes   |
  125.             for                     |     No     |    Yes     |   Yes   |
  126.             switch/case             |     No     |    Yes     |   Yes   |
  127.             goto                    |     No     |    Yes     |   Yes   |
  128.             Conditional Expressions |     No     |    Yes     |   Yes   |
  129.             Inline assembler        |    Yes     |    Yes     |   Yes   |
  130.             = Pre-Processor ========+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
  131.             #define (basic)         |    Yes     |    Yes     |   Yes   |
  132.             #define (Parameterized) |     No     |     No     |   Yes   |
  133.             #define (Multi-line)    |     No     |     No     |   Yes   |
  134.             #undef                  |     No     |     No     |   Yes   |
  135.             #include (single level) |    Yes     |    Yes     |   Yes   |
  136.             #include (nested)       |     No     |    Yes     |   Yes   |
  137.             #ifdef/#ifndef          |     No     |    Yes     |   Yes   |
  138.             = Misc features ========+ SMALL-C V1 + SMALL-C V2 + MICRO-C +
  139.             Optimization            |     No     |    Yes     |   Yes   |
  140.             Multiple memory models  |     No     |     No     |   Yes   |
  141.             Make/touch utility      |     No     |     No     |   Yes   |
  142.             Source linker           |     No     |     No     |   Yes   |
  143.             68HC08 code generator   |     No     |     No     |   Yes   |
  144.             6809 code generator     |     No     |     No     |   Yes   |
  145.             68HC11 code generator   |     No     |     No     |   Yes   |
  146.             68HC16 code generator   |     No     |     No     |   Yes   |
  147.             8080 code generator     |    Yes     |    Yes     |   Yes   |
  148.             8051 code generator     |     No     |     No     |   Yes   |
  149.             8086 code generator     |     No     |    Yes     |   Yes   |
  150.             8096 code generator     |     No     |     No     |   Yes   |
  151.             Complete standard lib   |     No     |    Yes     |   Yes   |
  152.             Interrupt serial I/O    |     No     |     No     |   Yes   |
  153.             Windowing library       |     No     |     No     |   Yes   |
  154.             TSR support             |     No     |     No     |   Yes   |
  155.     MICRO-C .vs. SMALL-C                                             Page: 3
  156.  
  157.  
  158.        2.2 Generated code quality
  159.     
  160.              To test the actual performace  of  code  generated  by  MICRO-C
  161.           against  code  generated  by  SMALL-C,  I  used  this  "Sieve   of
  162.           Eratosthenes" prime number generator program, taken from the  BYTE
  163.           benchmarks:
  164.     
  165.     
  166.     
  167.     
  168.     
  169.     /*
  170.      * The classic "Sieve of Eratosthenes" prime number pr